package com.jf.StudenManage.common;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;


public class DataTools {
    private static DataSource cpds;
    private static Connection conn;

    static {
        cpds = new ComboPooledDataSource();
        try {
            conn = cpds.getConnection();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public static void excuteSql(String sql) {
        try {
            Statement st = conn.prepareStatement(sql);
            st.execute(sql);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    public static ResultSet excuteQuery(String sql) {
        try {
            Statement st = conn.prepareStatement(sql);
            return st.executeQuery(sql);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return null;
        }
    }


}
